package spritebehavior;

import sprite.Sprite;
import utility.Bounce;
import gamehandlers.GameHandler;


/**
 * Defines the default
 * 
 * @author Seon Kang
 * 
 */
public class DefaultSpriteBehavior implements Behavior {
    private Sprite mySprite;
    private GameHandler myGameHandler;

    /**
     * sets the GameHandler
     * @param gh GameHandler
     */
    @Override
    public void setGameHandler(GameHandler gh) {
        myGameHandler = gh;
    }

    /**
     * Default Sprites just follow their velocity.
     */
    public void move () {
        mySprite.getCenter().translate(mySprite.getVelocity().x,
                mySprite.getVelocity().y);
    }

    /**
     * By default, Sprites don't have any specific actions.
     */
    public void doSpriteSpecificAction () {
    }

    protected Sprite getSprite () {
        return mySprite;
    }

    protected void setSprite (Sprite sprite) {
        this.mySprite = sprite;
    }

    @Override
    public void update () {
        move();
        if (myGameHandler.isHitLeftRightWall(mySprite)) {
            Bounce.apply(mySprite,"Horizontally");
        }
        if (myGameHandler.isHitTopBottomWall(mySprite)) {
            Bounce.apply(mySprite,"Vertically");
        }
    }
}
